package com.ss.android.wenda.d;

import android.app.Activity;
import android.view.View;

import com.ss.android.article.base.app.AppData;
import com.ss.android.article.common.model.ShareData;
import com.ss.android.article.common.share.abs.AbsShareHelper;
import com.ss.android.article.common.share.helper.CommonHtmlShareHelper;
import com.ss.android.article.common.share.log.ShareRespEntry;
import com.ss.android.article.share.d.e;
import com.ss.android.article.share.e.b;
import com.ss.android.article.share.entity.ShareAction;
import com.ss.android.article.share.entity.ShareImageBean;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.common.util.UrlBuilder;
import com.ss.android.wenda.model.Question;
import org.json.JSONObject;

public final class a implements b {
    public ShareData a;
    public JSONObject b;
    private Activity c;
    private String d;
    private Question e;

    public a(Activity arg1, String arg2, Question arg3) {

        this.c = arg1;
        this.d = arg2;
        this.e = arg3;
    }

    public final boolean a(com.ss.android.article.share.entity.a arg12, View arg13, com.ss.android.article.share.c.a arg14) {
        long v4 = 0;
        int v0 = this.a != null ? 1 : 0;
        if(v0 != 0) {
            switch(arg12.e) {
                case 1: {
                    MobClickCombiner.onEvent(this.c, this.d, "share_weixin_moments", v4, v4, this.b);
                    this.a(this.a, true);
                    return false;
                }
                case 2: {
                    MobClickCombiner.onEvent(this.c, this.d, "share_weixin", v4, v4, this.b);
                    this.a(this.a, false);
                    return false;
                }
                case 3: {
                    MobClickCombiner.onEvent(this.c, this.d, "share_qq", v4, v4, this.b);
                    new e(this.c).a(ShareAction.qq).b(this.a.mContent).a(this.a(this.a)).c(a(this.a, "mobile_qq", "mobile_qq")).a(new ShareImageBean(b(this.a))).a();
                    return false;
                }
                case 11: {
                    new CommonHtmlShareHelper(this.c).a(this.e, new Object[0]);
                    return false;
                }
            }

            return false;
        }

        return false;
    }

    private String a(ShareData arg3) {
        String v0 = arg3.mTitle;
        if(android.support.design.a.isTextEmpty(v0)) {
            v0 = this.c.getString(com.ss.android.article.browser.R.string.app_name);
        }

        return v0;
    }

    private static String a(ShareData arg3, String arg4, String arg5) {
        String v0 = arg3.mShareUrl;
        if((android.support.design.a.isTextEmpty(v0)) || (android.support.design.a.isTextEmpty(arg4)) || (android.support.design.a.isTextEmpty(arg5))) {
            v0 = "";
        }
        else {
            UrlBuilder v1 = new UrlBuilder(v0);
            if(!android.support.design.a.isTextEmpty(arg4)) {
                if(("weixin".equals(arg4)) || ("weixin_moments".equals(arg4))) {
                    v1.addParam("wxshare_count", 1);
                }

                v1.addParam("tt_from", arg4);
            }

            if(!android.support.design.a.isTextEmpty(arg5)) {
                v1.addParam("utm_source", arg5);
            }

            v1.addParam("utm_medium", "topic_android");
            v1.addParam("utm_campaign", "client_share");
            v0 = v1.build();
        }

        return v0;
    }

    private void a(ShareData arg10, boolean arg11) {
        String v1 = arg11 ? "weixin_moments" : "weixin";
        String v0 = arg11 ? "weixin_moments" : "weixin";
        String v3 = a(arg10, v1, v0);
        v1 = this.a(arg10);
        v0 = arg11 ? v1 : arg10.mContent;
        String v4 = b(arg10);
        String v5 = this.a.mTitle;
        String v6 = this.a.mShareSource;
        int v2 = arg11 ? 1 : 0;
        ShareRespEntry v7 = new ShareRespEntry(211, v2);
        AbsShareHelper.entry = v7;
        v7.title = v5;
        try {
            AbsShareHelper.entry.n = Long.valueOf(v6).longValue();
        }
        catch(Exception v2_1) {
            AbsShareHelper.entry.n = 0;
        }

        e v5_1 = new e(this.c, AppData.getInstance().isShareExtendedObjectEnabled());
        ShareAction v2_2 = arg11 ? ShareAction.wxtimeline : ShareAction.wx;
        v5_1.a(v2_2).c(v3).a(v1).b(v0).a(new ShareImageBean(v4)).a();
    }

    private static String b(ShareData arg2) {
        String v0 = arg2.mImageUrl;
        if(android.support.design.a.isTextEmpty(v0)) {
            v0 = "http://p0.pstatp.com/medium/6399/2275149767";
        }

        return v0;
    }
}

